<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="content">
        <h:form>
            <p:panel >
                <f:facet name="header">
                    <p:outputLabel value="Pharmacy Variant Adjustment"/>      
                    <h:panelGroup style="float: right;">
                        <p:commandButton value="All Request"
                                        action="#{variantAdjustment.createAll()}"
                                       ajax="false" ></p:commandButton>
                    </h:panelGroup>
                </f:facet>
                <h:panelGrid columns="4" >
                    <h:outputLabel value="From Date"/>
                    <p:calendar id="frmDate" value="#{variantAdjustment.fromDate}" 
                                navigator="true"  pattern="dd MMMM yyyy HH:mm:ss" >
                    </p:calendar>
                    <h:outputLabel value="To Date"/>
                    <p:calendar id="toDate" value="#{variantAdjustment.toDate}" 
                                navigator="true" pattern="dd MMMM yyyy HH:mm:ss"  >
                    </p:calendar>   
                    
                </h:panelGrid>                  
                <p:spacer height="20"/>
                

                <p:dataTable id="tbl" value="#{variantAdjustment.searchBills}"
                             paginator="true" rows="20"  lazy="true"
                             paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"  
                             rowsPerPageTemplate="5,10,15" var="b">

                    <p:column headerText="Report ID">                     
                        <h:outputLabel  value="#{b.deptId}">                              
                        </h:outputLabel>                        
                    </p:column>
                    
                    <p:column headerText="Date">                      
                        <h:outputLabel  value="#{b.createdAt}">
                            <f:convertDateTime pattern="dd MM yyyy"/>
                        </h:outputLabel>                        
                    </p:column>

                    <p:column headerText="Time">                      
                        <h:outputLabel  value="#{b.createdAt}">
                            <f:convertDateTime pattern="HH:mm:ss a"/>
                        </h:outputLabel>                          
                    </p:column>

                    <p:column headerText="Deprtment" filterBy="#{b.department.name}">                      
                        #{b.department.name}                         
                    </p:column> 

                    <p:column headerText="Reported Person" filterBy="#{b.creater.webUserPerson.nameWithTitle}">
                        #{b.creater.webUserPerson.nameWithTitle}
                    </p:column>


                    <p:column headerText="Adjusted Person" filterBy="#{b.referenceBill.creater.webUserPerson.nameWithTitle}" >
                        <h:outputLabel value="#{b.referenceBill.creater.webUserPerson.nameWithTitle}"  rendered="#{b.referenceBill.cancelled eq false}" >                        
                        </h:outputLabel>
                    </p:column>

                    <p:column headerText="Adusted ReportId" filterBy="#{b.forwardReferenceBill.id}" >                       
                        <h:outputLabel  value="#{b.forwardReferenceBill.id}" rendered="#{b.forwardReferenceBill.cancelled eq false}"/>                         
                    </p:column>

                    <p:column headerText="Adjust">
                        <p:commandButton ajax="false" value="Adjust" 
                                        action="pharmacy_variant_adjustment">
                            <f:setPropertyActionListener target="#{variantAdjustment.reportedBill}" value="#{b}"/>
                        </p:commandButton>
                    </p:column>
                    <p:column headerText="View Reported Bill">
                        <p:commandButton ajax="false" value="View Reported" action="pharmacy_reprint_variant_report" >
                            <f:setPropertyActionListener target="#{variantAdjustment.reportedBill}" value="#{b}"/>
                        </p:commandButton>
                    </p:column>
                    <p:column headerText="View Adjusted Bill">
                        <p:commandButton ajax="false" value="View Adjusted Bill" action="pharmacy_reprint_variant_report">
                            <f:setPropertyActionListener target="#{variantAdjustment.reportedBill}" value="#{b.forwardReferenceBill}"/>
                        </p:commandButton>
                    </p:column>
                </p:dataTable>
            </p:panel>            
        </h:form>
    </ui:define>  

</ui:composition>
